package org.example;

class My_Thread extends Thread {
    @Override
    public void run() {
        while(true){
            System.out.println("hallo World");
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
        }
    }
}

public class hallo_World {
    public static void main(String[] args) throws InterruptedException {
        Thread t = new My_Thread();
        t.start();
        //t.run();  这样写并没有创建新的线程，一直使用主线程
        while(true) {
            System.out.println("hallo Thread");
            Thread.sleep(1000);
        }
    }
}
